//
//  def_primary_expression.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_primary_expression_h
#define compilation_def_primary_expression_h

/*: IDENTIFIER {printf("primary_expression IDENTIFIER %s\n", $1);}
| CONSTANT {printf("primary_expression CONSTANT %s\n", $1);}
| '(' expression ')' {printf("primary_expression (expression)\n");}
| IDENTIFIER '(' ')' {printf("primary_expression IDENTIFIER ()\n");}
| IDENTIFIER '(' argument_expression_list ')' {printf("primary_expression IDENTIFIER (argument expression list)\n");}
| IDENTIFIER INC_OP {printf("primary_expression IDENTIFIER INC OP\n");}
| IDENTIFIER DEC_OP {printf("primary_expression IDENTIFIER DEC OP\n");}
;
*/
struct def_primary_expression{
	void * parent;
	int type;
	char * constant;
	struct def_expression * expression;
	char * identifier;
	struct def_argument_expression_list * argument_expression_list;
};

struct def_primary_expression * primary_expression_create(void * parent){
	struct def_primary_expression * p = malloc(sizeof(*p));
	p->parent = parent;
	p->type = 0;
	return p;
}

void primary_expression_print(struct def_primary_expression * p){
	switch(p->type){
		case 1:
			printf("%s",p->identifier);
			break;
		case 2:
			printf("%s",p->constant);
			break;
		case 3:
			printf("(");
			expression_print(p->expression);
			printf(")");
			break;
		case 4:
			printf("%s ()", p->identifier);
			break;
		case 5:
			printf("%s (", p->identifier);
			printf("???\n");
			argument_expression_list_print(p->argument_expression_list);
			printf(")");
			break;
		case 6:
			printf("%s ++", p->identifier);
			break;
		case 7:
			printf("%s --", p->identifier);
			break;
	}
}
#endif
